package cn.edu.nuc.fourth.dto;

import java.util.List;

public class PageInfo {
	// 当前页
	private int current = 1;
	// 总记录数
	private int count;
	// 显示五条记录
	private int offset = 5;
	// 总页数
	private int total;
	// limit后数值 第一个
	private int start;

	// 传进来什么这个list就是什么类型的
	private List<?> list;

	/**
	 * @param current
	 */
	public PageInfo(int current) {
		this.current = current;
	}

	/**
	 * 
	 */
	public PageInfo() {
	}

	public int getCurrent() {
		return current;
	}

	public void setCurrent(int current) {
		this.current = current;
	}

	public int getCount() {
		return count;
	}

	// 设置总数 记录总数判断总页数
	public void setCount(int count) {
		this.count = count;

		this.setTotal(this.count / this.offset + ((this.count % this.offset) > 0 ? 1 : 0));
	}

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		if (offset > 0)
			this.offset = offset;
	}

	public int getTotal() {
		return total;
	}

	// 可有可无
	public void setTotal(int total) {
		this.total = total;
	}

	public int getStart() {

		this.start = (this.current - 1) * this.offset;

		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}

	@Override
	public String toString() {
		return "PageInfo [current=" + current + ", count=" + count + ", offset=" + offset + ", total=" + total
				+ ", start=" + start + ", list=" + list + "]";
	}

}
